package com.ruoyi.chatmessage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.chatmessage.domain.Chatmessage;
import com.ruoyi.chatmessage.service.IChatmessageService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * chatmessageController
 * 
 * @author ruoyi
 * @date 2025-05-14
 */
@RestController
@RequestMapping("/chatmessage/chatmessage")
public class ChatmessageController extends BaseController
{
    @Autowired
    private IChatmessageService chatmessageService;

    /**
     * 查询chatmessage列表
     */
    @PreAuthorize("@ss.hasPermi('chatmessage:chatmessage:list')")
    @GetMapping("/list")
    public TableDataInfo list(Chatmessage chatmessage)
    {
        startPage();
        List<Chatmessage> list = chatmessageService.selectChatmessageList(chatmessage);
        return getDataTable(list);
    }

    /**
     * 导出chatmessage列表
     */
    @PreAuthorize("@ss.hasPermi('chatmessage:chatmessage:export')")
    @Log(title = "chatmessage", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Chatmessage chatmessage)
    {
        List<Chatmessage> list = chatmessageService.selectChatmessageList(chatmessage);
        ExcelUtil<Chatmessage> util = new ExcelUtil<Chatmessage>(Chatmessage.class);
        util.exportExcel(response, list, "chatmessage数据");
    }

    /**
     * 获取chatmessage详细信息
     */
    @PreAuthorize("@ss.hasPermi('chatmessage:chatmessage:query')")
    @GetMapping(value = "/{chatMessageId}")
    public AjaxResult getInfo(@PathVariable("chatMessageId") Long chatMessageId)
    {
        return success(chatmessageService.selectChatmessageByChatMessageId(chatMessageId));
    }

    /**
     * 新增chatmessage
     */
    @PreAuthorize("@ss.hasPermi('chatmessage:chatmessage:add')")
    @Log(title = "chatmessage", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Chatmessage chatmessage)
    {
        return toAjax(chatmessageService.insertChatmessage(chatmessage));
    }

    /**
     * 修改chatmessage
     */
    @PreAuthorize("@ss.hasPermi('chatmessage:chatmessage:edit')")
    @Log(title = "chatmessage", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Chatmessage chatmessage)
    {
        return toAjax(chatmessageService.updateChatmessage(chatmessage));
    }

    /**
     * 删除chatmessage
     */
    @PreAuthorize("@ss.hasPermi('chatmessage:chatmessage:remove')")
    @Log(title = "chatmessage", businessType = BusinessType.DELETE)
	@DeleteMapping("/{chatMessageIds}")
    public AjaxResult remove(@PathVariable Long[] chatMessageIds)
    {
        return toAjax(chatmessageService.deleteChatmessageByChatMessageIds(chatMessageIds));
    }
}
